package br.com.consultsystems.dominio.financeiro;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

import br.com.consultsystems.dominio.cadastro.Condominio;
import br.com.consultsystems.dominio.tipos.StatusFinanceiro;

@Entity
@Table(name = "balancete")
@SequenceGenerator(name = "operacao", sequenceName = "operacao",  allocationSize = 1)
@XmlRootElement
public class Balancete implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2039801289566978780L;

	@Id
	@Column(name = "id", nullable = false, insertable = true, updatable = false)
	@GeneratedValue(generator = "operacao", strategy = GenerationType.SEQUENCE)
	private Long id;
	
	@OneToOne
	@JoinColumn(name = "id_condominio", nullable = false, insertable = true, updatable = true)
	private Condominio condominio;	

	@Column(name = "datavencimento", nullable = false, insertable = true, updatable = false)
	@Temporal(TemporalType.DATE)
	private Date dataVencimento;

	@Column(name = "status", nullable = false, insertable = true, updatable = true, length = 10)
	@Enumerated(EnumType.STRING)
	private StatusFinanceiro status;
	
	public Balancete() {
		super();
	}

	public Long getId() {
		return id;
	}


	public void setId(Long id) {
		this.id = id;
	}


	public Condominio getCondominio() {
		return condominio;
	}

	public void setCondominio(Condominio condominio) {
		this.condominio = condominio;
	}

	public Date getDataVencimento() {
		return dataVencimento;
	}

	public void setDataVencimento(Date dataVencimento) {
		this.dataVencimento = dataVencimento;
	}

	public StatusFinanceiro getStatus() {
		return status;
	}

	public void setStatus(StatusFinanceiro status) {
		this.status = status;
	}

	@Override
	public String toString() {
		return "Competencia [id=" + id + ", condominio=" + condominio
				+ ", dataVencimento=" + dataVencimento + ", status=" + status
				+ "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Balancete other = (Balancete) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
}
